﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.Produce.Read.Api.Application.Commands.SheepCountCommands;

namespace S.Produce.Read.Api.Controllers
{
    /// <summary>
    /// 羊只统计控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SheepCountsController : ControllerBase
    {
        private readonly IMediator mediator;

        /// <summary>
        /// 构造方式注入
        /// </summary>
        /// <param name="mediator"></param>
        public SheepCountsController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 获取羊只实时存栏数量
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetRealtimeCount([FromQuery]RealtimeCountCommand command)
        {
            return Ok(await mediator.Send(command));
        }


    }
}
